<template>
  <div class="tags">
    <el-tag class="tag" v-for="tag in (props.tags as [SkcTag])" :key="tag.tagkey"
      :type="farmKnowViewUtils.getTagType(tag.type!)" @click="gotoTagSearchPage('TAG-' + tag.name)" round>
      {{ tag.name }}
    </el-tag>
  </div>
</template>
<script setup lang="ts">
import farmKnowViewUtils from '@/hook/farmKnowViewUtils';
import farmRoutUtils from '@/hook/farmRoutUtils';
import { useRouter } from 'vue-router';
import type { SkcTag } from '@/types/knows/SkcTag';
const router = useRouter();
const props = defineProps({
  tags: {
    type: Array as () => SkcTag[] | undefined, // 允许 tags 为 undefined
    required: true,
    default: () => [] // 设置默认值为空数组
  }
});


const gotoTagSearchPage = (tagWord: string) => {
  farmRoutUtils.gotoSearchPage({ word: tagWord, page: 1 }, router);
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
</script>
<style scoped>
/* 样式可以根据需要添加 */
.tags {
  padding-left: 10px;

  .tag {
    margin: 8px;
    cursor: pointer;
  }

  .tag:hover {
    opacity: 0.7;
  }

}
</style>
